<#setting number_format = "#"/>
<#assign edit = subforum?exists/>
<style type="text/css">@import url( ${contextPath}/templates/${templateName}/styles/style.css?${startupTime} );</style>

<form action="${contextPath}/jforum${extension}" method="post" name="form" id="form" accept-charset="${encoding}" onSubmit="return checkInput();" enctype="multipart/form-data">
<input type="hidden" name="action" value="${action}" />
<input type="hidden" name="module" value="${moduleName}" />


<script language="javascript">

function checkCategory()
{
	if (document.form.categories_id.selectedIndex < 0) {
		alert("${I18n.getMessage("Forums.Form.ChooseCategory")}");
		return false;
	}

	return true;
}

function checkInput()
{	
	var f = document.form;
	var s = /^\d+$/.test(f.subforum_order.value);
	if(!s){
		alert('${I18n.getMessage("Subforums.form.MustBeUnsignedInteger")}: "${I18n.getMessage("Subforums.Forum.Order")}"');
	}
	return s;
	//return checkGroups() && checkCategory();
	//return checkGroups() && checkCategory() && validateMailIntegration();
}

function showMailIntegration(checked)
{
	document.getElementById("mail_integration_tr").style.display = checked ? "" : "none";
}

function validateMailIntegration()
{
	var f = document.form;

	if (f.mail_integration.checked) {
		var baseMessage = "${I18n.getMessage("Forums.Form.FieldEmpty")}: ";
		
		if (f.forum_email.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.ForumEmail")}");
			f.forum_email.focus();
			return false;
		}

		if (f.pop_host.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopHost")}");
			f.pop_host.focus();
			return false;
		}

		if (f.pop_host.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopHost")}");
			f.pop_host.focus();
			return false;
		}

		if (f.pop_port.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopPort")}");
			f.pop_port.focus();
			return false;
		}

		if (f.pop_username.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopUsername")}");
			f.pop_username.focus();
			return false;
		}

		if (f.pop_password.value == "") {
			alert(baseMessage + "${I18n.getMessage("Forums.Form.PopPassword")}");
			f.pop_password.focus();
			return false;
		}
	}
}

function limitTextArea(field, limit)
{
	if (field.value.length > limit) {
		field.value = field.value.substring(0, limit);
	}
}
</script>
<input type="hidden" name="forum_id" value="${forum.id}" />
<#if edit>
<input type="hidden" name="subforum_id" value="${subforum.id}" />
</#if>

<table class="forumline" cellspacing="1" cellpadding="3" width="100%" border="0">
	<tr>
		<th class="thhead" valign="middle" colspan="2" height="25">${I18n.getMessage("Forums.Form.Title")}</th>
	</tr>
        
	<tr>
		<td class="row1" width="20%"><span class="gen">${I18n.getMessage("Subforums.Forum.ParentForum")}</span></td>
		<td class="row2">
		<span class="gensmall">
		<#if forum?exists>${forum.name}</#if>
		</span>
		</td>
	</tr>
	<tr>
		<td class="row1" width="20%"><span class="gen">${I18n.getMessage("Subforums.Forum.Moderate")}</span></td>
		<td class="row2">
			<span class="gensmall">
				<#if forum?exists && forum.isModerated()> ${I18n.getMessage("Subforums.Forum.Moderate.yes")} <#else> ${I18n.getMessage("Subforums.Forum.Moderate.no")} </#if>
			</span>
		</td>
	</tr>
	<tr>
		<td class="row1" width="38%"><span class="gen">${I18n.getMessage("Subforums.Forum.Name")}</span></td>
		<td class="row2">
		<span class="gensmall">
			<input type="text" class="post" style="WIDTH: 200px" maxlength="200" size="25" name="subforum_name" value="<#if subforum?exists> ${subforum.name} </#if>" />
		</span>
		</td>
	</tr>
	<tr>
		<td class="row1" width="38%"><span class="gen">${I18n.getMessage("Subforums.Forum.Order")}</span></td>
		<td class="row2">
		<span class="gensmall">
			<input type="text" class="post" style="WIDTH: 200px" maxlength="200" size="25" name="subforum_order" value="<#if subforum?exists>${subforum.order}</#if>" />
		</span>
		</td>
	</tr>
	

	<tr>
		<td class="row1"><span class="gen">${I18n.getMessage("Subforums.Forum.Description")}</span></td>
		<td class="row2"><textarea name="description" cols="40" rows="10" class="post" style="width: 100%" onKeyDown="limitTextArea(this, 255);" onKeyUp="limitTextArea(this, 255);"><#if subforum?exists>${subforum.description?default("")}</#if></textarea></td>
	</tr>
    
	<tr align="center">
		<td class="catbottom" colspan="2" height="28"><input class="mainoption" type="submit" value="${I18n.getMessage("Forums.Form.ClickToUpdate")}" name="submit" /></td>
	</tr>

</table>
</form>

<#if false && mailIntegration?exists>
	<script type="text/javascript">showMailIntegration(true);</script>
</#if>
